package com.see.viewer.application;

import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.AbstractSelect.Filtering;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class IndustryComboBox extends VerticalLayout implements
        Property.ValueChangeListener {

    private static final String[] cities = new String[] { "Berlin", "Brussels",
            "Helsinki", "Madrid", "Oslo", "Paris", "Stockholm" };

    public IndustryComboBox() {
        setSpacing(false);

        ComboBox box = new ComboBox("");
        box.setInputPrompt("Please select Industry");

        for (int i = 0; i < cities.length; i++) {
            box.addItem(cities[i]);
        }

        box.setFilteringMode(Filtering.FILTERINGMODE_OFF);
        box.setImmediate(true);
        box.addListener(this);

        addComponent(box);
    }

    /*
     * Shows a notification when a selection is made.
     */
    public void valueChange(ValueChangeEvent event) {
        getWindow().showNotification("Selected city: " + event.getProperty());

    }
}